package org.hbnu;

import java.util.Objects;

//书类
public class Book {

    //编号
    public int id;

    //名字
    public String name;

    //价格
    public float price;

    //无参数构造方法

    public Book() {
    }


    //有参数构造方法
    public Book(int id, String name, float price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    //设置与获取方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    //比较方法

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return id == book.id && Float.compare(price, book.price) == 0 && Objects.equals(name, book.name);
    }

    //对象的哈希值（指纹）
    @Override
    public int hashCode() {
        return Objects.hash(id, name, price);
    }
}